//
// SdlGraph.hpp for nibbler in /home/titouan/Dropbox/Code/nibbler-epitech-2017/inc
//
// Made by creach titouan
// Login   <titouan@epitech.net>
//
// Started on  Thu Mar 13 16:57:54 2014 creach titouan
// Last update Sun Apr  6 20:25:37 2014 ledins
//

#ifndef GRAH_HPP
# define GRAH_HPP

#include <iostream>
#include <string>
#include <vector>
#include <gtk/gtk.h>
#include "IGraph.hpp"

class Graphics : public IGraph
{
public:
  Graphics(int argc, char **argv, int w, int h);
  void loadImages(const std::map<IGraph::Image, std::string> &loadMap);
  void drawBlock(IGraph::Image img, int x, int y);
  void openWindow();
  IGraph::Event getNextEvent();
  void wait(unsigned int d) const;
  unsigned int getCurrentTime() const;
  void display();
  void clearScreen(char r, char g, char b);
  void loadFont(const std::string &fontPath);
  void writeText(char r, char g, char b, const std::string &text, int x, int y);
  Point getTextSize(const std::string &text) const;
  void pause();

  IGraph::Event on_key_press(GtkWidget* button, GdkEventKey *, gpointer data);

  ~Graphics();

  static void button_clicked_call_back(GtkWidget *widget, GdkEventKey *,  gpointer *data);
  static void delete_event(gpointer *data);

  IGraph::Event _event;
private:
  void TestLoading(GError *, const std::string &imageName);
  GtkWidget * _window;
  GtkWidget * _draw;
  std::vector<GdkPixbuf *> _imgs;
  gint _w;
  gint _h;
};

extern "C" IGraph *create(int argc, char **argv, int w, int h)
{
  return new Graphics(argc, argv, w, h);
}

extern "C" void destroy(IGraph *obj)
{
  delete obj;
}

#endif
